package designPattern.factory.factorymethod;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public abstract class OrderPizza {

    public OrderPizza(){
        Pizza pizza = null;
        String orderType;//订购披萨类型
        do {
            orderType = getType();
            pizza = creatPizza(orderType);
            //输出pizza制作过程
            pizza.prepare();
            pizza.bake();
            pizza.cut();
            pizza.box();
        }while (true);
    }

    //定义一个抽象方法 createPizza 由各个工厂子类自己实现
    abstract Pizza creatPizza(String orderType);

    //写一个方法，输入获得披萨种类
    private String getType() {
        try {
            BufferedReader strin = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("input pizza种类：");
            String str = strin.readLine();
            return str;
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }
    }
}
